<div class="uimssVarieties" style="height: 100%;width:100%;overflow:auto;position: relative;padding-top: 42px;background-color: #fff;">
    <div class="button-group-head" style="position: absolute;left: 0;top: 0;width: 100%;border-bottom: none;">


        <span class="hrp-btn hrp-btn-add" id="settleAccounts" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>结账</span>
        <span class="hrp-btn hrp-btn-add" id="updatePrice" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>更新单价</span>
        <span class="hrp-btn hrp-btn-add" id="excelExportForManySheet" style="float: right;"><i class="fa fa-file-excel-o" style="padding-right: 4px;"></i>导出多sheet</span>
        <span class="hrp-btn hrp-btn-add" id="excelExport" style="float: right;"><i class="fa fa-file-excel-o" style="padding-right: 4px;"></i>导出excel</span>
        <span class="hrp-btn hrp-btn-add" id="openDialog" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>查询</span>
        <!--<span  class="hrp-btn hrp-btn-refresh"><i class="fa fa-refresh" style="padding-right: 4px;"></i>刷新</span>-->


        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">开始日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeKsrq" name="dept">
        </span>
        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">结束日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeJsrq" name="dept">
        </span>




    </div>
    <!--<div class="jxkhzbk-toolbar" style="position: absolute;left: 0;top: 42px;width: 100%;">-->
        <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
            <!--<input id="receiverId" name="dept">-->
        <!--</span>-->
        <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">收货方:</span>-->

        <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
            <!--<input id="supplierId" name="dept">-->
        <!--</span>-->
        <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">发货方:</span>-->




        <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
            <!--<input id="varietiesId" name="dept">-->
        <!--</span>-->
        <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">种类:</span>-->
    <!--</div>-->
    <div style="height: 100%;width: 100%;border:1px solid #cccccc;position: relative;">
        <div class="uimssVarieties-content-left" style="position: absolute;left: 0;top:0;height: 100%;width: 450px;">
            <div style="position: absolute;left: 0;top:0;width:150px;height:100%;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input"  data-action="varietiesIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索分类"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="varietiesIdTree"></ul>
                </div>
            </div>
            <div style="position: absolute;left: 150px;top:0;width:150px;height:100%;;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input"   data-action="supplierIddSearch"  style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索发货地"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="supplierIdTree"></ul>
                </div>
            </div>
            <div style="position: absolute;right: 0;top:0;width:150px;height:100%;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input" data-action="receiverIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索收货地"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="receiverIdTree"></ul>
                </div>
            </div>
        </div>
        <div class="uimssVarieties-content-main" style="height: 100%;margin-left: 450px;border-left:1px solid #ccc;overflow: auto;">
            <table id="dg" class="easyui-datagrid" style="width:100%;">
                <!--<thead>-->
                <!--<tr>-->
                <!--<th  width="15%">Item ID(15%)</th>-->
                <!--<th  width="15%">Product(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th width="15%">List Price(15%)</th>-->
                <!--</tr>-->
                <!--</thead>-->
            </table>
        </div>
    </div>




    <div id="editActionDialog"  class="ss-dialog" style="width:600px;height: 460px;margin-top: -300px;margin-top: -230px;">
        <span class="ss-dialog-close" style="">X</span>
        <div class="ss-dialog-head" style="">
            添加
        </div>
        <div class="ss-dialog-content">
            <div class="row" style="height: 60px;">
                <input type="hidden" id="idkey" value="-1"/>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">砂石种类:</span>
                <span style="width:35%;float:left;padding-top: 10px;"><input  id="varietiesId" type="text"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">开始日期</span>
                <span style="width:35%;float:left;padding-top: 10px;"><input id="sendTime" type="text" value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
            </div>
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">发货方:</span>
                <span style="width:35%;float:left;padding-top: 10px;"><input  id="supplierId" type="text"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">收货方:</span>
                <span style="width:35%;float:left;padding-top: 10px;"><input  id="receiverId" type="text"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>

            </div>
            <!--<div class="row" style="height: 60px;">-->
            <!--<span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">备注:</span>-->
            <!--<span style="width:35%;float:left;"><input  id="memo" type="text" placeholder="备注" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>-->
            <!--<span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">停用标志</span>-->
            <!--<span style="width:35%;float:left;padding-top: 21px;font-size: 14px;cursor: pointer;">-->
            <!--<span class="self-radio" data-radio="true" id="qy" data-value="1"><i class="fa fa-dot-circle-o"></i>启用</span>-->
            <!--<span class="self-radio" id="ty" data-value="0"><i class="fa fa-circle-o"></i>停用</span>-->
            <!--</span>-->
            <!--</div>-->
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">单价:</span>
                <span style="width:35%;float:left;"><input  id="price" type="text" placeholder="单价" value="0"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">车毛重:</span>
                <span style="width:35%;float:left;"><input  id="cmz" type="text" placeholder="车毛重" value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
            </div>
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">车身重:</span>
                <span style="width:35%;float:left;"><input  id="csz" type="text" placeholder="车身重"  value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">净重:</span>
                <span style="width:35%;float:left;"><input  id="jz" type="text" placeholder="净重"  value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
            </div>
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">次数:</span>
                <span style="width:35%;float:left;"><input  id="times" type="text" placeholder="净重" value="0"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">车牌号:</span>
                <span style="width:35%;float:left;"><input  id="cph" type="text" placeholder="请输入车牌号"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
            </div>
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">接收人:</span>
                <span style="width:35%;float:left;"><input  id="jsr" type="text" placeholder="车身重" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">备注:</span>
                <span style="width:35%;float:left;"><input  id="memo" type="text" placeholder="备注" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>

            </div>
        </div>
        <div  class="ss-dialog-head" style="">
            <span class="hrp-btn hrp-btn-delete" style="float: right;" id="btn-cancel"><i class="fa fa-close" style="padding-right: 4px;"></i>取消</span>
            <span class="hrp-btn hrp-btn-add" style="float: right;" id="btn-save"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>
        </div>
    </div>
    <div id="mask-model" class="mask-model" style=""></div>


    <div id="updatePriceActionDialog"  class="ss-dialog" style="width:300px;height: 200px;margin-left: -100px;margin-top: -200px;">
        <span class="ss-dialog-close" style="">X</span>
        <div class="ss-dialog-head" style="">
            更新单价
        </div>
        <div class="ss-dialog-content">
            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">单价:</span>
                <span style="width:85%;float:left;"><input  id="update-price" type="text" placeholder="单价" value="0"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
            </div>

        </div>
        <div  class="ss-dialog-head" style="margin-top: 20px;">
            <span class="hrp-btn hrp-btn-delete" style="float: right;" id="btn-price-cancel"><i class="fa fa-close" style="padding-right: 4px;"></i>取消</span>
            <span class="hrp-btn hrp-btn-add" style="float: right;" id="btn-price-save"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>
        </div>
    </div>


</div>


<script type="text/javascript">

    var dHeight = $(".uimssVarieties").height();

    var UserIndexPage={
        tableName:"UIMSS_SUPPLIERINFO",
        init:function () {


            this.initEvnets();
            this.initSendTimeKsrqCombox();
            this.initSendTimeJsrqCombox();

            this.initReceiverTree();
            this.initVarietiesTree();
            this.initSupplierTree();

            this.initDateCombox();

        },
        initVarietiesTree:function (searchValue) {
            $('#varietiesIdTree').tree({
                url:'common/getUimssVarietiesTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initSupplierTree:function (searchValue) {
            $('#supplierIdTree').tree({
                url:'common/getUimssSupplierTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initReceiverTree:function (searchValue) {
            $('#receiverIdTree').tree({
                url:'common/getUimssReceiverTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initSendTimeJsrqCombox:function () {

            var that= this;
            $('#sendTimeKsrq').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeKsrq').datebox('setValue', that.formatterDate(that.setDateMonth(new Date())));
        },
        initSendTimeKsrqCombox:function () {

            var that= this;
            $('#sendTimeJsrq').datebox({
                formatter : function(date){
                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeJsrq').datebox('setValue', that.formatterDate(new Date()));
        },
        initEvnets:function () {
            var that = this;
            $(window).resize(function () {
                $('#dg').datagrid("resize")
            })
            $("#openDialog").on("click",function () {
                that.initGrid();
                $("#idkey").val("-1");
                //$('#editActionDialog').slideDown(300);
                //$("#mask-model").slideDown(300);
            })


            //多sheet页导出
            $("#excelExportForManySheet").on("click",function () {
                var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');

                var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                var varietiesIdStr='';
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(i<varietiesIdArr.length-1){
                        varietiesIdStr+=varietiesIdArr[i].id+',';
                    }else{
                        varietiesIdStr+=varietiesIdArr[i].id;
                    }
                }

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdStr='';
                for(var i=0;i<supplierIdArr.length;i++){
                    if(i<supplierIdArr.length-1){
                        supplierIdStr+=supplierIdArr[i].id+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                    }
                }
                // console.log(supplierIdStr);

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }

                window.location.href="export/excelExportForManySheet?sendTimeKsrq="+sendTimeKsrq+"&sendTimeJsrq="+sendTimeJsrq+"&varietiesIdStr="+varietiesIdStr+"&supplierIdStr="+supplierIdStr+"&receiverIdStr="+receiverIdStr+"&page=1&rows=60";

            })


            //结账功能
            $("#settleAccounts").on("click",function () {


                $.messager.confirm('提醒',"是否确认结账",function(r){
                    if (r){

                        var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                        var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');

                        //alert("1");
                        var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                        var varietiesIdStr='';
                        for(var i=0;i<varietiesIdArr.length;i++){
                            if(i<varietiesIdArr.length-1){
                                varietiesIdStr+=varietiesIdArr[i].id+',';
                            }else{
                                varietiesIdStr+=varietiesIdArr[i].id;
                            }
                        }
                        //alert("2");
                        //console.log(varietiesIdStr);

                        var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                        var supplierIdStr='';
                        for(var i=0;i<supplierIdArr.length;i++){
                            if(i<supplierIdArr.length-1){
                                supplierIdStr+=supplierIdArr[i].id+',';
                            }else{
                                supplierIdStr+=supplierIdArr[i].id;
                            }
                        }
                        //console.log(supplierIdStr);

                        var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                        var receiverIdStr='';
                        for(var i=0;i<receiverIdArr.length;i++){
                            if(i<receiverIdArr.length-1){
                                receiverIdStr+=receiverIdArr[i].id+',';
                            }else{
                                receiverIdStr+=receiverIdArr[i].id;
                            }
                        }
                        //console.log(receiverIdStr);

                        $.post("transprotRecord/updateIsSettleAccounts", {
                            "isSettleAccounts":1,
                            "sendTimeKsrq":sendTimeKsrq,
                            "sendTimeJsrq":sendTimeJsrq,
                            "varietiesIdStr":varietiesIdStr,
                            "supplierIdStr":supplierIdStr,
                            "receiverIdStr":receiverIdStr
                        }, function (result) {
                            if (result.status == 200) {
                                $("#mask-model").hide(50);
                                $('#updatePriceActionDialog').hide(50);
                                $.messager.show({title: '提示', msg: '结账成功', timeout: 1000, showType: 'slide'});
                            } else {
                                $.messager.show({title: '提示', msg: '结账失败', timeout: 1000, showType: 'slide'});
                            }
                        })




                    }
                });






            })

            $("#updatePrice").on("click",function () {
                $("#mask-model").show(10);
                $('#updatePriceActionDialog').show(10);
            })

            $("#btn-price-cancel").on("click",function () {
                $("#mask-model").hide(50);
                $('#updatePriceActionDialog').hide(50);
            })
            $("#btn-price-save").on("click",function () {
                var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');


                var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                var varietiesIdStr='';
                //console.log(varietiesIdArr);
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(i<varietiesIdArr.length-1){
                        varietiesIdStr+=varietiesIdArr[i].id+',';
                    }else{
                        varietiesIdStr+=varietiesIdArr[i].id;
                    }
                }

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdStr='';
                for(var i=0;i<supplierIdArr.length;i++){
                    if(i<supplierIdArr.length-1){
                        supplierIdStr+=supplierIdArr[i].id+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                    }
                }
                //console.log(supplierIdStr);

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }
                //console.log(receiverIdStr);

                var price = $("#update-price").val();
                $.post("transprotRecord/updateTransportRecordDataPrice", {
                    "sendTimeKsrq":sendTimeKsrq,
                    "sendTimeJsrq":sendTimeJsrq,
                    "varietiesIdStr":varietiesIdStr,
                    "supplierIdStr":supplierIdStr,
                    "receiverIdStr":receiverIdStr,
                    "price":price
                }, function (result) {
                    if (result.status == 200) {
                        $("#mask-model").hide(50);
                        $('#updatePriceActionDialog').hide(50);
                        $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                    } else {
                        $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                    }
                })

            })


            $(".ss-dialog-close").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
                $('#updatePriceActionDialog').hide();
            })

            $("#excelExport").on("click",function () {
                var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');

                var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                var varietiesIdStr='';
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(i<varietiesIdArr.length-1){
                        varietiesIdStr+=varietiesIdArr[i].id+',';
                    }else{
                        varietiesIdStr+=varietiesIdArr[i].id;
                    }
                }

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdStr='';
                for(var i=0;i<supplierIdArr.length;i++){
                    if(i<supplierIdArr.length-1){
                        supplierIdStr+=supplierIdArr[i].id+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                    }
                }
               // console.log(supplierIdStr);

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }

                window.location.href="export/export1?sendTimeKsrq="+sendTimeKsrq+"&sendTimeJsrq="+sendTimeJsrq+"&varietiesIdStr="+varietiesIdStr+"&supplierIdStr="+supplierIdStr+"&receiverIdStr="+receiverIdStr+"&page=1&rows=60";

            })

            $(".uimssVarieties").on("keyup",".search-input",function () {
                var newValue = $(this).val();
                var oldValue=$(this).data("oldValue");
                if(!oldValue){
                    oldValue="";
                }
                if( $(this).attr("data-action")=="varietiesIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                       // console.log("varietiesIdSearch");
                        that.initVarietiesTree(newValue);
                    }
                }else if($(this).attr("data-action")=="supplierIddSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        //console.log("supplierIddSearch");
                        that.initSupplierTree(newValue);
                    }
                }else if( $(this).attr("data-action")=="receiverIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        //console.log("receiverIdSearch");
                        that.initReceiverTree(newValue);
                    }
                }

                $(this).data("oldValue",newValue);

            })

            $("#btn-save").on("click",function () {
                    that.saveData();
            })

            $("#btn-cancel").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
            })

            //修改
            $(".uimssVarieties").on("click",".btn-edit",function () {
                var id = $(this).attr("data-id");
                var sendTime = $.trim($(this).attr("data-sendTime"));
                var varietiesId = $.trim($(this).attr("data-varietiesId"));
                var supplierId = $.trim($(this).attr("data-supplierId"));
                var receiverId = $.trim($(this).attr("data-receiverId"));
                var cph = $.trim($(this).attr("data-cph"));
                var cmz = $.trim($(this).attr("data-cmz"));
                var csz = $.trim($(this).attr("data-csz"));
                var jz = $.trim($(this).attr("data-jz"));
                var jsr = $.trim($(this).attr("data-jsr"));
                var times = $.trim($(this).attr("data-times"));
                var memo = $.trim($(this).attr("data-memo"));
                var price = $.trim($(this).attr("data-price"));

                $("#idkey").val(id);
                $('#sendTime').datebox('setValue', sendTime);
                UserIndexPage.initVarietiesComBox(varietiesId);
                UserIndexPage.initSupplierComBox(supplierId);
                UserIndexPage.initReceiverCombox(receiverId);

                $("#cph").val(cph);
                $("#cmz").val(cmz);
                $("#csz").val(csz);
                $("#jz").val(jz);
                $("#jsr").val(jsr);
                $("#times").val(times);
                $("#memo").val(memo);
                $("#price").val(price);

                $('#editActionDialog').slideDown(300);
                $("#mask-model").slideDown(300);
            })
        },
        saveData:function () {
            var that = this;

            var sendTime = $('#sendTime').datebox('getValue');

            var varietiesId = $('#varietiesId').combobox('getValue');
            localStorage.setItem("varietiesId",varietiesId);
            var varietiesName = $('#varietiesId').combobox('getText');

            var supplierId = $('#supplierId').combobox('getValue');
            localStorage.setItem("supplierId",supplierId);
            var supplierName = $('#supplierId').combobox('getText');


            var receiverId = $('#receiverId').combobox('getValue');
            localStorage.setItem("receiverId",receiverId);
            var receiverName = $('#receiverId').combobox('getText');

            var price=$.trim($("#price").val());
            if(!that.checkNumber(price)){
                $.messager.show({title: '提示', msg: '请输入合法的单价', timeout: 1000, showType: 'slide'});
                return;
            }

            var cph = $.trim($("#cph").val());
            var cmz = $.trim($("#cmz").val());
            if(!that.checkNumber(cmz)){
                $.messager.show({title: '提示', msg: '请输入合法的车毛重', timeout: 1000, showType: 'slide'});
                return;
            }
            var csz =$.trim($("#csz").val());
            if(!that.checkNumber(csz)){
                $.messager.show({title: '提示', msg: '请输入合法的车身重', timeout: 1000, showType: 'slide'});
                return;
            }
            var jz =$.trim($("#jz").val()) ;
            if(!that.checkNumber(jz)){
                $.messager.show({title: '提示', msg: '请输入合法的净重', timeout: 1000, showType: 'slide'});
                return;
            }
            var jsr = $.trim($("#jsr").val());
            var times = $.trim($("#times").val());
            if(!that.checkNumber(times)){
                $.messager.show({title: '提示', msg: '请输入次数', timeout: 1000, showType: 'slide'});
                return;
            }
            var memo = $.trim($("#memo").val());


            var tybz = $(".self-radio[data-radio='true']").attr("data-value");
            $.post("transprotRecord/saveTransportRecordData", {
                "id":$("#idkey").val(),
                "sendTime":sendTime,
                "varietiesId":varietiesId,
                "varietiesName":varietiesName,
                "price":price,
                "supplierId":supplierId,
                "supplierName":supplierName,
                "receiverId":receiverId,
                "receiverName":receiverName,
                "cph":cph,
                "cmz":cmz,
                "csz":csz,
                "jz":jz,
                "jsr":jsr,
                "times":times,
                "memo":memo
            }, function (result) {
                if (result.status == 200) {
                    $('#editActionDialog').slideUp(300);
                    $("#mask-model").slideUp(300);
                    $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                } else {
                    $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                }
            })
        },
        //得到当前日期
        formatterDate : function(date,type) {
            var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
            var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1);
            return date.getFullYear() + '-' + month + '-' + day;

        },
        //验证字符串是否是数字
        checkNumber:function(theObj) {
            var reg = /^[0-9]+.?[0-9]*$/;
            if (reg.test(theObj)) {
                return true;
            }
            return false;
        },
        initGrid:function () {

            var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
            var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');

            var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
            var varietiesIdStr='';
            for(var i=0;i<varietiesIdArr.length;i++){
                if(i<varietiesIdArr.length-1){
                    varietiesIdStr+=varietiesIdArr[i].id+',';
                }else{
                    varietiesIdStr+=varietiesIdArr[i].id;
                }
            }

            var supplierIdArr = $('#supplierIdTree').tree('getChecked');
            var supplierIdStr='';
            for(var i=0;i<supplierIdArr.length;i++){
                if(i<supplierIdArr.length-1){
                    supplierIdStr+=supplierIdArr[i].id+',';
                }else{
                    supplierIdStr+=supplierIdArr[i].id;
                }
            }

            var receiverIdArr = $('#receiverIdTree').tree('getChecked');
            var receiverIdStr='';
            for(var i=0;i<receiverIdArr.length;i++){
                if(i<receiverIdArr.length-1){
                    receiverIdStr+=receiverIdArr[i].id+',';
                }else{
                    receiverIdStr+=receiverIdArr[i].id;
                }
            }
            //console.log(receiverIdStr);


            $('#dg').datagrid({
                url: "transprotRecordQuery/getTransportRecordByPage",
                queryParams: {
                    "sendTimeKsrq":sendTimeKsrq,
                    "sendTimeJsrq":sendTimeJsrq,
                    "varietiesIdStr":varietiesIdStr,
                    "supplierIdStr":supplierIdStr,
                    "receiverIdStr":receiverIdStr
                },
                pagination: true,
                singleSelect: true,
                height:dHeight-2,   //表格高度，可指定高度，可自动
                pageNumber: 1,
                pageSize: 60,
                pageList: [30, 60,90],
                fitColumns:true,
                remoteSort:true,
                loadMsg: "正在加载数据",
                nowrap: false,
                striped: true,  //奇偶行是否使用不同的颜色
                columns:[
                    [
                        //{field:'id',title:'编号',width:"5%"},
                        {field:'row',title:'序号',width:"5%",sortable:true},
                        {field:'sendTime',title:'送货日期',width:"10%",sortable:true},
                        {field:'varietiesName',title:'种类',width:"10%",sortable:true},
                        {field:'supplierName',title:'发货方',width:"12%",sortable:true},
                        {field:'receiverName',title:'收货方',width:"12%",sortable:true},
                        //{field:'cph',title:'车牌号',width:"10%"},
//                        {field:'cmz',title:'车毛重',width:"5%"},
                        //{field:'csz',title:'车身重',width:"5%"},
                        {field:'price',title:'单价',width:"5%",sortable:true},
                        {field:'jz',title:'净重',width:"9%"},
                        {field:'je',title:'金额',width:"9%"},
                        {field:'jsr',title:'接收人',width:"8%"},
                        //{field:'times',title:'次数',width:"5%"},
                        {field:'memo',title:'备注',width:"15%"},
                        {
                            field: 'isSettleAccounts', title: '是否结账', width: "10%",
                            formatter: function (value, row, index) {
                                if(value=="1"){
                                    return "<span style='color:red;'>已结账</span>";
                                }else{
                                    return "<span >未结账</span>";
                                }
                            }
                        },
                        {
                            field: 'edit', title: '操作', width: "5%",
                            formatter: function (value, row, index) {
                                return "<a class='btn-edit' href='#' data-id='"+row.id+"'  data-sendTime='"+row.sendTime+"' data-varietiesId='"+row.varietiesId+"' data-supplierId='"+row.supplierId+"' data-receiverId='"+row.receiverId+"' data-cph='"+row.cph+"' data-cmz='"+row.cmz+"' data-csz='"+row.csz+"' data-jz='"+row.jz+"' data-jsr='"+row.jsr+"' data-times='"+row.times+"' data-memo='"+row.memo+"' data-price='"+row.price+"'>修改</a>"
                            }
                        }
                    ]
                ]
            });

        },
        setDateMonth:function (date) {
            var d = new Date(date);
            var month = d.getMonth();
            if (11 === month) {
                var year = d.getFullYear();
                d.setMonth(0);
                d.setFullYear(year + 1);
            } else {
                d.setMonth(month - 1);
            }
            return d;
        },
        initVarietiesComBox:function (id) {
            $('#varietiesId').combobox({
                url:"common/getUimssVarietiesDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {
                    //$("#price").val(record.value);
                },
                onLoadSuccess:function () {

                }
            });
        },
        initSupplierComBox:function (id) {
            $('#supplierId').combobox({
                url:"common/getUimssSupplierDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initReceiverCombox:function (id) {
            $('#receiverId').combobox({
                url:"common/getUimssReceiverDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initDateCombox:function () {

            var that= this;
            $('#sendTime').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });

            $('#sendTime').datebox('setValue', that.formatterDate(new Date()));
        }
    }
    $(function () {
        UserIndexPage.init();
    })
</script>